<template>
  <yy-paging
    v-model="dataList"
    @query="queryList"
    ref="paging"
    :auto="automatic"
    @scroll="scroll"
    :refresher-enabled="false"
  >
    <template #top>
      <u-navbar
        back-text="返回"
        :is-back="false"
        :background="{ backgroundColor: isScroll ? '#FFFFFF' : 'transparent' }"
        :border-bottom="false"
        :custom-style="{ transition: 'background-color 0.3s ease-in-out' }"
      >
      </u-navbar>
    </template>
    <template #empty>
      <yy-empty></yy-empty>
    </template>
    <template #loadingMoreNoMore>
      <yy-nomore></yy-nomore>
    </template>
    <view class="p-4">333333333333777</view>
  </yy-paging>
</template>

<script>
  export default {
    data() {
      return {
        isScroll: false,
        dataList: [],
        automatic: false
      }
    },
    async onLoad(options) {
      vk.redirectTo('/pages/login/index')
      return

      let res = await vk.myfn.login().catch(err => {
        console.log('err==> ', err)
        console.log('err==> ', err.code)
        console.log('err==> ', err.code)

        if (err.code == 30003) {
          vk.redirectTo('/pages/index/index')
          // #ifdef APP
          uni.closeAuthView()
          // #endif
          return
        }
        // 30002 其他
        if (err.code == 30002) {
          vk.redirectTo('/pages/login/index')
          // #ifdef APP
          uni.closeAuthView()
          // #endif

          return
        }
        vk.redirectTo('/pages/login/index')
        // #ifdef APP
        uni.closeAuthView()
        // #endif

        // 30008
      })

      if (!res) return

      // return
      console.log('res==> ', res)
    },
    methods: {
      scroll(e) {
        this.isScroll = e.detail.scrollTop > 0
      },
      async queryList(page, limit) {
        this.$refs.paging.complete([1, 1, 1])
      }
    }
  }
</script>

<style lang="scss" scoped></style>
